﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using database;//delete и drop
using database_insert;
using database_select;

namespace database
{
    class Program
    {//добавили один рандом
        static void Main(string[] args)
        {
            //впоследствие этот кусок кода будет в generic, как основная инфа о подключение
           MySql.Data.MySqlClient.MySqlConnection conn;
            MySql.Data.MySqlClient.MySqlCommand cmd=new MySql.Data.MySqlClient.MySqlCommand();


            conn = new MySql.Data.MySqlClient.MySqlConnection("server=127.0.0.1;uid=root;pwd=ALEX42695;database=mydb;");
            conn.Open();
            cmd.Connection = conn;

            /* 
            for(int i=2;i<16;i++)
            {
                cmd.CommandText = "INSERT INTO users(user_id,login,password,role,mail) VALUES(" + i + ",'A','A'," + i + ",'A')";
                cmd.ExecuteNonQuery();
            cmd.CommandText = "INSERT INTO instruments (lat,lng,status,registred,name_device,status_map,id_instrument,id_owner) " +
             "VALUES(1.0,1.0," + i + ",'1000-01-01 00:00:00','A','A'," + i + "," + i + ")";
            cmd.ExecuteNonQuery();
            cmd.CommandText = "INSERT INTO user_instruments(user_id,id_instrument) VALUES(" + i + "," + i + ")";
            cmd.ExecuteNonQuery();
            cmd.CommandText = "INSERT INTO events(name,def,severity,instruments_id_instrument) VALUES('problem','problem111'," + i + "," + i + ")";

            cmd.ExecuteNonQuery();
              }
            cmd.CommandText = "SELECT login, mail FROM users WHERE user_id = 1";
            MySql.Data.MySqlClient.MySqlDataReader myreader = cmd.ExecuteReader();
            

            while(myreader.Read())
            {
                Console.WriteLine("{0}, {1}", myreader.GetString(0), myreader.GetString(1));
            }
            Console.ReadKey();*/

            Select_data sd = new Select_data(conn, cmd);
            Console.WriteLine(sd.select_users("login", 1));
            Console.ReadKey();
        } 
    }
}
